

import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class ClassList extends JFrame{
    public ClassList(String userid){

        SQLOperation sql=new SQLOperation();

        setTitle("Class List");
        Container container=getContentPane();
        setLayout(new BorderLayout());

        JPanel titlePanel=new JPanel();

        JLabel title=new JLabel("Class Information");
        title.setFont(new Font("",Font.BOLD,20));

        titlePanel.add(title);

        String[] typeAttributes={"typeID","tName"};

        Object[][] typeInfo=sql.search("DeviceType",typeAttributes,"shanchu",1);

        JTable classList=new JTable(typeInfo,typeAttributes);

        classList.setRowHeight(30);
        classList.setFont(new Font("",Font.PLAIN,15));

        classList.setEnabled(true);
        classList.getTableHeader().setFont(new Font("",Font.BOLD,20));
        JScrollPane scrollPane=new JScrollPane(classList);

        add(scrollPane,BorderLayout.CENTER);

        JButton back=new JButton("Back");
        back.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                setVisible(false);
            }
        });

        JButton addOne=new JButton("Add one");
        addOne.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                // ADD
                setVisible(false);
                new ClassAdd(userid);


            }
        });




        JPanel buttons=new JPanel();
        buttons.add(back);
        buttons.add(addOne);

        add(buttons,BorderLayout.SOUTH);






        setSize(600,500);
        setResizable(false);
        setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
        setVisible(true);



    }
}
